﻿
using Irony.Compiler;

namespace IronLua.Ast {

	public class MemberExpression : Expression {

		readonly Expression target;
		readonly string name;

		public Expression Target {
			get { return target; }
		}

		public string Name {
			get { return name; }
		}

		public override LuaNodeType NodeType {
			get { return LuaNodeType.MemberExpression; }
		}

		public MemberExpression (CompilerContext context, NonTerminal nonTerminal, SourceLocation location, AstNodeList childNodes)
			: base (context, nonTerminal, location, childNodes)
		{
			target = ChildNodes [0].ToExpression ();
			name = (ChildNodes [2] as Token).Text;
		}

		public override void Accept (ILuaAstVisitor visitor)
		{
			visitor.VisitMemberExpression (this);
		}
	}
}
